package map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description: 遍历for循环
 * @date 2022/9/25 21:25
 */
public class MapFor {

    public static void main(String[] args) {
        Map map = new HashMap(10);
        map.put("oyz","cool");
        map.put("oyl","cool");
        map.put(null,"cool");
        map.put(null,null);
        map.put("cool",null);
        // 第一组: 先取出所有的key,然后根据key从map中取出对应的值
        Set set = map.keySet();
        // 增强for
        for (Object key : set) {
            System.out.println(key);
        }
        System.out.println("---------");
        // 利用迭代器
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
